﻿/*----------------------------------------------------------------
// Copyright (C) 2017 佰林格都信息科技有限公司 版权所有。 
//
// 文件名：BMember
// 文件功能描述：提供处理各种管理[TB_Member]表成员的业务逻辑的方法
//
// 创建标识：jinchuanliang 2018-07-14
//
// 修改标识：
// 修改描述：
//----------------------------------------------------------------*/
using System;
using System.Data.Common;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Text;

using FamilyTree.DAL;
using FamilyTree.Entity;
using BLGD.OrderTracking.Tool;

namespace FamilyTree.BLL
{
    /// <summary>
    /// 提供处理各种管理成员  [TB_Member]表的业务逻辑的方法
    /// </summary>
	/// <author>jinchuanliang 2018-07-14</author>
    public sealed class BMember
    {
        /// <summary>
        /// 私有的构造函数。
        /// </summary>
        private BMember()
        {
        }

        /// <summary>
        /// 公共的入口。
        /// </summary>
        /// <returns></returns>
        public static BMember BLL
        {
            get { return Bll; }
        }

        /// <summary>
        /// 业务逻辑层对象
        /// </summary>
        private readonly static BMember Bll = new BMember();

        /// <summary>
        /// 数据访问层对象
        /// </summary>
        internal readonly static DMember Dal = new DMember();


        /// <summary>
        /// 添加成员数据
        /// </summary>
        /// <param name="model">数据实体</param> 
        /// 创建人：jinchuanliang 时间：2016-09-22
        /// <returns></returns>
        public int Insert(MemberEntity model)
        {
            return Dal.Insert(GetSafetyModel(model));
        }


        /// <summary>
        /// 修改tb_member数据
        /// </summary>
        /// <param name="model">数据实体</param> 
        /// 创建人：jinchuanliang 时间：2018-07-14
        /// <returns></returns>
        public bool Update(MemberEntity model)
        {
            return Dal.Update(GetSafetyModel(model));
        }

        /// <summary>
        /// 删除tb_member数据
        /// </summary>
        /// <param name="memberId">成员ID </param> 
        /// 创建人：jinchuanliang 时间：2018-07-14
        /// <returns></returns>
        public bool SignDelete(int memberId)
        {
            return Dal.SignDelete(memberId);
        }


        /// <summary>
        ///  获取ModelList
        /// </summary> 
        /// <param name="exid"></param>
        /// <returns></returns>
        public MemberEntity GetModel(int memberId)
        {
            return Dal.GetModel(memberId);
        }


        /// <summary>
        ///  获取ModelList
        /// </summary> 
        /// <param name="familyInfoId"></param>
        /// <returns></returns>
        public List<MemberEntity> GetModels(int familyInfoId)
        {
            return Dal.GetModels(familyInfoId);
        }

        /// <summary>
        ///  获取ModelList
        /// </summary> 
        /// <param name="familyInfoId"></param>
        /// <param name="parentId"></param>
        /// <returns></returns>
        public List<MemberEntity> GetModels(int familyInfoId,int parentId)
        {
            return Dal.GetModels(familyInfoId,parentId);
        }

        /// <summary>
        ///  获取ModelList
        /// </summary> 
        /// <param name="familyInfoId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public List<MemberEntity> GetModels(int familyInfoId, int pageIndex, int pageSize)
        {
            return Dal.GetModels(familyInfoId, pageIndex, pageSize);
        }

        /// <summary>
        /// //安全过虑
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static MemberEntity GetSafetyModel(MemberEntity model)
        {
            MemberEntity mod = new MemberEntity();
            mod.MemberId = model.MemberId;
            mod.MemberName = XSSTool.Filter(model.MemberName);
            mod.Sex = XSSTool.Filter(model.Sex);
            mod.CardNumber = XSSTool.Filter(model.CardNumber);
            mod.Phone = XSSTool.Filter(model.Phone);
            mod.Birthday = model.Birthday;
            mod.FamilyInfoId = model.FamilyInfoId;
            mod.Ranking = model.Ranking;
            mod.PicUrl = XSSTool.Filter(model.PicUrl);
            mod.Profile = XSSTool.Filter(model.Profile);
            mod.DieTime = model.DieTime;
            mod.IsDelete = model.IsDelete; 
            mod.ParentId = model.ParentId;
            mod.Remarks = XSSTool.Filter(model.Remarks);

            return mod;

        }


    }
}

